package com.tedu.supermarket_01.controller;

import com.tedu.supermarket_01.pojo.PageUtill;
import com.tedu.supermarket_01.pojo.Provider;
import com.tedu.supermarket_01.services.ProviderServies;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller

@RequestMapping("/provider")
public class ProviderController {
    @Autowired
    ProviderServies providerServies;

    //  分页显示
    @RequestMapping("/list")
    public ModelAndView list(@RequestParam(name = "currentPageNo" ,defaultValue = "1") int currentPageNo,
                             @RequestParam(name = "size",defaultValue = "5") int size){
    // 调用供应商的服务层
        System.out.println(currentPageNo+"-----------"+totalPageCount);

        List<Provider> providerByPage = providerServies.getProviderByPage(currentPageNo, size);
        PageUtill pageUtill = new PageUtill();
        pageUtill.setCode("200");
        pageUtill.setId(201);
        pageUtill.setMsg("恭喜你，成功获取数据");
        pageUtill.setData(providerByPage);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("ModelAndView");
//        modelAndVie

        return modelAndView;


    }

}
